package com.example.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * 相当于springapplicationcontext.xml
 */
@Configuration
public class configBean {

    //配置负载均衡template
    //IRule
    //AvailabilityFilterTeringRule ：先过滤掉崩溃的服务，在进行轮询操作
    // RandomRule 随机
    //RoundRobinRule 轮询
    @Bean
    @LoadBalanced //ribbon开启
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

//    @Bean
//    public IRule MyRule(){
//        return new RandomRule();
//    }
}
